package com.qingcheng.demo;

import com.aliyun.oss.OSSClient;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * @author lin.jia
 */
public class OssDemo {
    public static void main(String[] args) {
        //域名
        final String endpoint = "http://oss-cn-beijing.aliyuncs.com/";
        //AccessKey ID
        final String accessKeyId = "LTAI4FoUxUfCp4VQnWUPzYpT";
        //AccessKeySecret
        final String accessKeySecret = "3RxneBn0gpzGwuXBZJeYD0fL6VzhSK";
        //BucketName
        final String bucketName = "qingcheng-jialin";
        //OSS客户端
        OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream("C:\\Users\\lin.jia\\Desktop\\AE28CB35-ACA5-4359-AA66-E97209BA1D25.JPG");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //bucketName OSS库  test.JPG 文件名  inputStream输入流
        ossClient.putObject(bucketName, "test.JPG", inputStream);
        ossClient.shutdown();
    }
}
